/*
 * KIMWONSORK@GMAIL.COM
 * COPYRIGHT CRAYONSOFT All rights reserved.
 * 2013오후 9:07:00
 * kws
 */

package com.crayon.account.fragments;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.Loader;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import com.crayon.account.dao.DAOAccount;
import com.crayon.account.data.EDAType;
import com.crayon.account.data.ENMapKey;
import com.crayon.account.data.ItemGroup;
import com.crayon.account.fragments.ui.FragmentPieChart.OnPieChartDataBinder;
import com.crayon.account.fragments.ui.FragmentTopSum;
import com.crayon.sharemenu.R;
import com.crayon.util.UTILPieChartDemo01View;

import org.afree.chart.AFreeChart;
import org.afree.data.general.PieDataset;

import java.util.Date;
import java.util.HashMap;
import java.util.List;


public class FragmentChildChartIOType extends FragmentChildChart 
implements 
OnClickListener
,OnPieChartDataBinder
{

	public static FragmentChildChartIOType onCrateInstance(Date time){
		FragmentChildChartIOType f = new FragmentChildChartIOType();
		Bundle args =new Bundle();
		args.putLong(PARAM_DATE, time.getTime());
		f.setArguments(args);
		return f;
	}
	
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		return inflater.inflate(R.layout.fragment_child_piechart,container, false);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);

		FragmentTransaction tr = getChildFragmentManager().beginTransaction();
		tr.replace(R.id.fragment_top_sum, FragmentTopSum.onCreateInstance(getmDate().getTime()));
		tr.commit();
		
		ProgressBar progressBar = (ProgressBar)getView().findViewById(R.id.progress_loading);
		progressBar.setVisibility(View.VISIBLE);
		OnReLoad();

	}


	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void onLoadFinished(Loader<HashMap<ENMapKey, Object>> arg0,
			HashMap<ENMapKey, Object> arg1) {
		// TODO Auto-generated method stub
		super.onLoadFinished(arg0, arg1);
	}

	@Override
	public Loader<HashMap<ENMapKey, Object>> onCreateLoader(int arg0,
			Bundle arg1) {
		// TODO Auto-generated method stub
		ProgressBar progressBar = (ProgressBar)getView().findViewById(R.id.progress_loading);
		progressBar.setVisibility(View.VISIBLE);
		return super.onCreateLoader(arg0, arg1);
	}

	@Override
	public PieDataset OnPieDataSet() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public AFreeChart createChart(PieDataset dataset) {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public boolean onCreateChartIncom(List<ItemGroup> groups,
			Fragment fragment, int resId) {
		// TODO Auto-generated method stub
		return false;
	}


	@Override
	public boolean onCreateChartOut(List<ItemGroup> groups, Fragment fragment,
			int resId) {
		// TODO Auto-generated method stub
		
		return false;
	}


	@Override
	public boolean onCreateChartSingle(List<ItemGroup> groups,
			Fragment fragment, int resId) {
		// TODO Auto-generated method stub
		UTILPieChartDemo01View.OnCrateChartByArray(groups,
				String.format("%s %s", getString(R.string.segmenu_write_outcom),getString(R.string.segmenu_summary_total)),this,resId);

		return false;
	}
	@Override
	public String onCreateChartKey(DAOAccount item) {
		// TODO Auto-generated method stub
		String key=getString(R.string.dao_key_nocate);
		for(EDAType ioType:EDAType.values()){
			if(item.getxIOType()==ioType.getKey()){
				key = getString(ioType.getnIdTitle());
			}
		}

		return key;
	}

	

}
